package com.gary.prometheus.controller;

import com.gary.prometheus.entity.HttpSd;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author peng_rui
 * @date 2022/4/13
 */
@Slf4j
@RestController
public class ExploreController {
    @Value("${server.port}")
    private Integer port;
    @RequestMapping(value = "/api/hosts", method = RequestMethod.GET)
    public List<HttpSd> httpSdConfigJson() {
        List<HttpSd> list = new ArrayList<>();
        //1
        HttpSd httpSd = new HttpSd();
        ArrayList<String> hostList = new ArrayList<>();
        hostList.add("localhost : " + port);
        httpSd.setTargets(hostList);

        HashMap<String, String> map = new HashMap<>();
        map.put("appName", "gary-prometheus");
        map.put("idcName", "阿里云");
        httpSd.setLabels(map);
        list.add(httpSd);
        log.info("接口被调用了。。。。。");
        return list;
    }
}
